﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace LS.Validations
{
    public class SeiralNumberRegExAttribute : RegularExpressionAttribute, IClientValidatable
    {
        public SeiralNumberRegExAttribute(string pattern)
            : base(pattern)
        {

        }
        public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            string errMsg = FormatErrorMessage(metadata.GetDisplayName());
            ModelClientValidationRule rule = new ModelClientValidationRegexRule(errMsg, this.Pattern);
            return new[] { rule };
        }
    }
}